package net.helix.element;

import net.helix.core.transform.Transform;
import net.helix.core.transform.ViewTransform;
import net.helix.engine.timeline.Timeline;
import net.helix.engine.timeline.layer.TimelineLayer;

public class Element_Camera extends ViewNodeElement {
	Timeline timeline;
	TimelineLayer layer;
	float frame;
	
	ViewTransform viewTransform;
	
	// TODO: cameras need near and far to be able to be set.
	public Element_Camera(Timeline timeline, TimelineLayer layer, float frame, ViewTransform viewTransform){
		// TODO: make it contain a list of children layers which is included in
		// rendering...?
		super(null);
		
		this.timeline = timeline;
		this.layer = layer;
		this.frame = frame;
		this.viewTransform = viewTransform;
		this.transform = viewTransform.getTransform();
	}
	@Override
	public void render() {
		// Since a camera can only be set as a Root of a ViewPath, then
		// the camera should handle all GL calls thinking it contains the top
		// of the hierarchy...
		
		// TODO: properties??
		
		int l = layer.children.size();
		for(int i=0;i<l;i++){
			layer.children.get(i).renderAtFrame(frame);
		}
		// TODO: maybe consider rendering the camera here as well...
	}
	public Timeline getTimeline(){
		return timeline;
	}
	@Override
	public String getSymbolName() {
		return layer.name;
	}
	public TimelineLayer getLayer(){
		return layer;
	}
	
	public ViewTransform getViewTransform(){
		
		// TODO: properties will set these values
		viewTransform.setFOV(45);
		viewTransform.setRatio(1);
		viewTransform.setNear(1);
		viewTransform.setFar(10000);
		
		//viewTransform.setTransform(transform);
		
		return viewTransform;
		
	}
}
